package io.zcoder.innoway.adapters;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import io.zcoder.innoway.activities.EntryDetailActivity;
import io.zcoder.innoway.commons.Constants;
import io.zcoder.innoway.fragments.EntryBMIFragment;
import io.zcoder.innoway.fragments.EntryOtherFragment;

public class ViewPagerEntryAdapter extends FragmentPagerAdapter {

    EntryDetailActivity mDetailActivity;

    public ViewPagerEntryAdapter(EntryDetailActivity activity, FragmentManager fm) {
        super(fm);
        mDetailActivity = activity;
    }

    @Override
    public Fragment getItem(int position) {
        Bundle bundle = new Bundle();
        bundle.putParcelable(Constants.DASHBOARD_EXTRAS, mDetailActivity.getDashboard());
        bundle.putInt(Constants.INDEX_EXTRAS, position);
        if (position == 0) {
            EntryBMIFragment fragment = new EntryBMIFragment();
            fragment.setArguments(bundle);
            return fragment;
        } else {
            EntryOtherFragment fragment = new EntryOtherFragment();
            fragment.setArguments(bundle);
            return fragment;
        }
    }

    @Override
    public int getCount() {
        return mDetailActivity.mTitle.length;
    }
}
